//package com.digiwin.escloud.test.bussiness.test;
//
//import com.alibaba.fastjson.JSONObject;
//import com.digiwin.escloud.test.core.entity.TestCaseEntity;
//import com.digiwin.escloud.test.core.parser.TestDataParser;
//import com.digiwin.escloud.test.core.parser.xml.XmlDataParser;
//import io.restassured.RestAssured;
//import io.restassured.response.ResponseBody;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.io.IOUtils;
//import org.springframework.http.HttpStatus;
//import org.testng.SkipException;
//import org.testng.annotations.*;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.lang.reflect.Method;
//import java.util.List;
//import java.util.Properties;
//
//import static io.restassured.RestAssured.given;
//import static org.hamcrest.MatcherAssert.assertThat;
//import static org.hamcrest.Matchers.equalTo;
//
///**
// * @Author yanggld
// * @Date 2020/4/15-10:45
// */
//@Slf4j
//public class SuiteConfig  extends AbstarctTestV1{
//	/**
//	 * 测试的接口地址
//	 */
//	public static String apiUrl = "1";
//	public static Long timeout = 2000L;
//	/**
//	 * 用户登录之后获取的token
//	 */
//	public static String token = null;
//	public static List<TestCaseEntity> testCaseEntityList = null;
//
//	private final String BASE_URI = "baseURI";
//	private final String BASE_PATH = "basePath";
//	private final String PORT = "port";
//	private final String TIMEOUT = "timeout";
//	private final String CONFIG_NAME = "application.properties";
//	private final String TEST_DATA_NAME = "testCase.xml";
//
//	private TestDataParser testDataParser;
//
//	@BeforeSuite(description = "测试套件前置处理方法")
//	public void beforeSuite() throws IOException {
//		testDataParser = new XmlDataParser();
//		InputStream dataInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(TEST_DATA_NAME);
//		String testData = IOUtils.toString(dataInputStream, "UTF-8");
//		testDataParser.parse(testData);
//		Properties ftpConfig = new Properties();
//		try {
//			testCaseEntityList = testDataParser.parse(testData);
//			InputStream configInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(CONFIG_NAME);
//			ftpConfig.load(configInputStream);
//			log.info("ftpConfig info is {} for test.", JSONObject.toJSONString(ftpConfig));
//		} catch (IOException e) {
//			e.printStackTrace();
//			throw new RuntimeException("get application.properties error.");
//		}
//		String baseUri = ftpConfig.getProperty(BASE_URI);
//		String basePath = ftpConfig.getProperty(BASE_PATH);
//		String port = ftpConfig.getProperty(PORT);
//		String timeoutStr = ftpConfig.getProperty(TIMEOUT);
//		try {
//			timeout = Long.parseLong(timeoutStr);
//		} catch (Exception e){
//			log.error("timeout is error.");
//		}
//		log.info("api url is {} for test.",(baseUri+port));
//		try {
//			RestAssured.baseURI = baseUri;
//			RestAssured.basePath = basePath;
//			RestAssured.port = Integer.parseInt(port);
//		} catch (Exception e) {
//			log.error("config is error.");
//			throw new SkipException("config is error.");
//		}
////		loginTest();
//		System.out.println("beforeSuite 11");
//	}
//
//	@AfterSuite(description = "测试套件后置处理方法")
//	public void afterSuite(){
//		System.out.println("AfterSuite 11");
//	}
//
//	@BeforeTest
//	public void beforeTest(){
//		System.out.println("BeforeTest");
//	}
//
//	@AfterTest
//	public void afterTest(){
//		System.out.println("AfterTest");
//	}
//
//	/**
//	 * 登录获取token
//	 */
//	@Test(dataProvider="dataProvider")
//	public void loginTest(TestCaseEntity testCaseEntity) {
//		String url = testCaseEntity.getUrl();
//		String requestParam = testCaseEntity.getRequestParam();
////		JSONObject requestParamJSON = JSONObject.parseObject(requestParam);
////		for (Map.Entry<String, Object> entry : requestParamJSON.entrySet()) {
////			url=url.replace("{"+entry.getKey()+"}",String.valueOf(entry.getValue()));
////		}
//		super.build(testCaseEntity,response -> {
////			assertThat(response.getBody().asString(), matchesJsonSchemaInClasspath("1.json"));
//			assertThat(response.getStatusCode(), equalTo(HttpStatus.OK.value()));
//			ResponseBody body = response.getBody();
//			log.info("----------------"+body.asString());
//			SuiteConfig.token = body.jsonPath().getString("token");
//		});
////		Response response =
////			given().when().queryParams(JSONObject.parseObject(requestParam, Map.class)).post(url).then()
////				.statusCode(200).body("error", equalTo(false)).body(matchesJsonSchemaInClasspath("1.json")).extract().response();
//	}
//
//	@DataProvider(name = "dataProvider")
//	public Object[][] dataProvider(Method method) {
//		for (TestCaseEntity testCaseEntity : testCaseEntityList) {
//			String name = testCaseEntity.getName();
//			if (method.getName().equals(name)) {
//				return new Object[][]{{testCaseEntity}};
//			}
//		}
//		return null;
//	}
//}
